//全局变量---------------------
//	var locationUrl = 'https://dev-api.otosaas.com';
//	var locationUrl = 'http://jhdp.test.otosaas.com/api'
	var locationUrl ='/api';
	var abc = 'test';
	var Channel = 'zmn';
//调取参数
	function GetQueryString(name){
	     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	     var r = window.location.search.substr(1).match(reg);
	     if(r!=null)return  decodeURI(r[2]); return null;
	}

//字体适配--------------------------------
	var docEl = document.documentElement,
	    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
	    recalc = function() {
	        //设置根字体大小
	        var myfontSize = 20 * (docEl.clientWidth/320);
//		        console.log(myfontSize);
	        if(myfontSize > 30){
	        	docEl.style.fontSize = "30px";
	        }else{
	        	 docEl.style.fontSize = 20 * (docEl.clientWidth/320) + 'px'; 
	        }
	       
	    };
	//绑定浏览器缩放与加载时间
	window.addEventListener(resizeEvt, recalc, false);
	document.addEventListener('DOMContentLoaded', recalc, false);


//ajax的封装---------------
	window.KJin={};
	KJin.ajax = function (url, data, opts,type) {
		$.ajax({
	        url: url,
	        data: data,
	        type: type,//data ? 'POST' : 'GET',
	        dataType: opts.dataType || 'json',
	        beforeSend: opts.beforeSend,
	        success: function(data){
	            if (data == null && !opts.noMsg) {
	                alert('您的网络有些问题，请稍后再试');
	                return false;
	            } else {
	                opts.success(data);
	            }
	        },
	        	error: function(XHR, info, errorThrown){
	        		console.log("XHR:===" + XHR);
	        		console.log("info:===" + info);
	        		console.log("errorThrown:===" + errorThrown);
	        }
	    });	
	};
/*
 使用方法
var url = baseAjaxUrl + '/service/list';
var data = {
    name:"KJin",
    age:"18"
};
var opts = {
    'noMsg': true,
    'success': function(re) {
  		console.log(re);    
    }
};
KJin.ajax(url, data, opts);
 * */
// 公共弹窗
	var publicAlert = {
		showAlert : function (content, btn1) {
			$('body').append(
				"<div id='mask'>"+"</div>"+
				"<div id='myAlert'>"+
					"<div id='alertHeader'>"+'温馨提示'+"</div>"+
					"<div id='alertMain'>"+
						"<div id='alertContent'>"+content+"</div>"+
					"</div>"+
					"<div id='alertBtn'>"+
						"<div id='confirm'>"+'确定'+"</div>"+
					"</div>"+
				"</div>"
			);
			if(btn1){
				$('#myAlert #confirm').text(btn1);
			}
			$('#mask').fadeIn(200);
			$('#myAlert').show(100);
			$('#myAlert').on('click','#confirm',function () {
				$('#mask').fadeOut(200);
				$('#myAlert').hide(100);
				return true;
			});
			$('#mask').on('click',function () {
				$('#mask').fadeOut(200);
				$('#myAlert').hide(100);
			});
		},
		showConfirm : function (content, btn1, btn2, onOk, onCancel) {
			$('body').append(
				"<div id='mask'>"+"</div>"+
				"<div id='myConfirm'>"+
					"<div id='confirmHeader'>"+'温馨提示'+"</div>"+
					"<div id='confirmMain'>"+
						"<div id='confirmContent'>"+content+"</div>"+
					"</div>"+
					"<div id='confirmBtn'>"+
						"<div id='confirm'>"+'确定'+"</div>"+
						"<div id='cancel'>"+'取消'+"</div>"+
					"</div>"+
				"</div>"
			);
			if(btn2){
				$('#cancel').text(btn2);
			}
			if(btn1){
				$('#myConfirm #confirm').text(btn1);
			}
			$('#mask').fadeIn(200);
			$('#myConfirm').show(100);
			$('#cancel').on('click',function () {
				$('#mask').fadeOut(200);
				$('#myConfirm').hide(100);
				if(onCancel){
					onCancel();
				}
			});
			$('#myConfirm').on('click','#confirm',function () {
				$('#mask').fadeOut(200);
				$('#myConfirm').hide(100);
				if(onOk){
					onOk();
				}
			})
			$('#mask').on('click',function () {
				$('#mask').fadeOut(200);
				$('#myConfirm').hide(100);
			});
		}
	};